package com.lizi.core.java.util.concurrent.atomic;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

public class AtomicTest {

	public static void main(String[] args) {
		AtomicInteger integer = new AtomicInteger();
	}
	//而volatile这个值的作用就是告诉VM：对于这个成员变量不能保存它的副本，要直接与共享成员变量交互
	private volatile int value;
	
	private Map<String, AtomicInteger> counter = new HashMap<String, AtomicInteger>();  
	private AtomicTest cvm = new AtomicTest();  
	  
	private void initCounter() {  
	     counter.put("cvm", new AtomicInteger(0));  
	}  
	
	//被调用一次自动+1    
	public AtomicTest getCvm() {  
	  
	        if (cvm != null) {  
	            counter.get("cvm").incrementAndGet();  
	        }  
	        return cvm;  
	    }  
}
